<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>打折购买糖果的最小开销</title>
</head>
<body>
  <script>
    function fn(nums) {
      nums.sort((a, b) => b - a);
      let res = 0;
      let len = nums.length;
      for (let i = 0; i < len; i++) {
        if (i % 3 === 0) {
          continue
        }
        res += nums[i - 1]
      }
      return res
    }
    console.log(fn([1, 2, 3]))
  </script>
</body>
</html>